#pragma once
#include <vector>
#include "fmod.h"
#include "fmod.hpp"

#define SOUNDMANAGER SoundManager::Instance()

struct SoundData
{
	FMOD::Sound*	sound;
	FMOD::Channel*	channel;
	unsigned int	id;
	float			vol;
};

struct MusicData
{
	FMOD::Sound*	stream;
	FMOD::Channel*	channel;
	unsigned int	id;
	float			vol;
};

class SoundManager
{
private:
	// private constructors
	SoundManager(void);
	SoundManager(const SoundManager&);
	SoundManager* operator=(const SoundManager&);
	~SoundManager(void);

protected:
	typedef std::vector<SoundData*> Sounds;
	typedef std::vector<MusicData*> Musics;

	FMOD::System*		mSoundSystem;
	Sounds				mSoundList;
	Musics				mMusicList;

	float				mSoundVolume;
	float				mMusicVolume;

public:
	void Update();

	void LoadSound(char *filename, unsigned int soundID, float relativeVolume);
	void LoadMusic(char *filename, unsigned int musicID, float relativeVolume);

	void SoundPlay(unsigned int soundID);
	void SoundStop(unsigned int soundID);
	void SoundStop(void);

	void MusicPlay(unsigned int musicID);
	void MusicStop(unsigned int musicID);
	void MusicStop(void);

	void Initialize(void);

	void Release(void);

	void SetVolume(float soundVol, float musicVol);
	
	// accessing the singleton
	static SoundManager* Instance();
};